package com.gobang.gobangboot.mapper;

import com.gobang.gobangboot.entity.User.User;
import com.gobang.gobangboot.entity.User.UserVO;
import com.gobang.gobangboot.mapper.provider.UserSqlProvider;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {

    @Select("select * from user where phone=#{phone}")
    User findByUsername(String phone);

    @Insert("insert into user(username, password, sex, avatar, phone, create_time, update_time)" +
            " VALUES(#{username}, #{password}, #{sex}, #{avatar}, #{phone},  #{createTime}, #{updateTime}) ")
    void insert(User user);

    @Select("select * from user where id = #{id}")
    User findById(Long id);

//    @UpdateProvider(type = UserSqlProvider.class, method = "updateUserSql")
//    @Update("update user set intro=#{user.intro} where id=#{userId}")
    // void updateUserInfo(UserVO user, Long userId);

    @Update("update user set avatar=#{urlPath} where id = #{id}")
    void updateAvatar(String urlPath, Long id);

    @Select("select * from user where phone=#{phone}")
    User findByPhone(String phone);

    void updateById(User user);
}
